#!/usr/bin/python3
# 文件名：client.py
import _thread

# 导入 socket、sys 模块
import socket
import sys

# 创建 socket 对象
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# 获取本地主机名
host = '39.103.180.180'

# 设置端口号
port = 9091
s.connect((host, port))
s.send("ly开始登录".encode('utf-8'))

def accept():
    while True:
        msg_res = s.recv(1024)
        print(msg_res.decode('utf-8'))
        #print("接收到的信息" + msg_res.decode('utf-8'))
def send():
    while True:
        msg=input();
        #print("开始发送==="+msg)
        s.send(msg.encode('utf-8'))

try:
   print("创建接收器线程")
   _thread.start_new_thread( accept,())
   print("创建发送器线程")
   _thread.start_new_thread( send,())
except:
   print ("Error: 无法启动线程")

while 1:
   pass
